import 'package:photo_manager/photo_manager.dart';

abstract class MediaItem {
  String get id;
  AssetType get type;

  // 判断是否为网络图片
  bool get isNetworkImage;

  // 获取网络URL（如果是网络图片）
  String? get networkUrl;

  // 获取AssetEntity（如果是本地资源）
  AssetEntity? get assetEntity;
}

// 本地媒体资源
class LocalMediaItem extends MediaItem {
  final AssetEntity _asset;

  LocalMediaItem(this._asset);

  @override
  String get id => _asset.id;

  @override
  AssetType get type => _asset.type;

  @override
  bool get isNetworkImage => false;

  @override
  String? get networkUrl => null;

  @override
  AssetEntity? get assetEntity => _asset;
}

// 网络媒体资源
class NetworkMediaItem extends MediaItem {
  final String _url;
  final AssetType _type;

  NetworkMediaItem(this._url, this._type);

  @override
  String get id => _url.hashCode.toString();

  @override
  AssetType get type => _type;

  @override
  bool get isNetworkImage => true;

  @override
  String? get networkUrl => _url;

  @override
  AssetEntity? get assetEntity => null;
}
